package com.marktotop.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.marktotop.entity.business.VaccineDevolution;
import com.marktotop.vo.business.SiteVaccineVO;
import com.marktotop.vo.business.VaccineDevolutionVO;
import org.apache.ibatis.annotations.Param;

import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author MarkToTop
 * @since 2021-07-16
 */
public interface VaccineDevolutionMapper extends BaseMapper<VaccineDevolution> {

    /**
     * 页展示所有疫苗下发记录列表，并进行模糊查询
     *
     * @param page
     * @param devolutionVO
     * @return
     */
    IPage<VaccineDevolutionVO> getDevolutionRecordByPage(Page<VaccineDevolutionVO> page, @Param("devolution") VaccineDevolutionVO devolutionVO);


    /**
     * 根据id查找下发记录对象
     *
     * @param id
     * @return
     */
    VaccineDevolutionVO getDevolutionRecordById(Long id);


    /**
     * 根据 疫苗id、接种点id 获取 下放记录
     *
     * @param vaccineId
     * @param vaccSiteId
     * @return
     */
    VaccineDevolution getInfoBySiteAndVacc(Long vaccineId, Long vaccSiteId);


    /**
     * 添加下发订单信息
     *
     * @param devolution
     */
    void insertOrderToSite(@Param("devolution") VaccineDevolution devolution);


    /**
     * 获取接种点疫苗记录
     *
     * @param vaccineSiteId
     * @param vaccineId
     * @return
     */
    SiteVaccineVO getRecordFormSite(@Param("siteId") Long vaccineSiteId,@Param("vaccineId") Long vaccineId);


    /**
     * 更新中间表库存数量
     *
     * @param recordFormSite
     */
    void updateCountRecord(@Param("record") SiteVaccineVO recordFormSite);


    /**
     * 查询中间表，判断接种点是否有疫苗记录
     *
     * @param id
     * @return
     */
    List<SiteVaccineVO> selectRecordsBySiteId(Long id);
}
